import React, {PropsWithChildren} from 'react'
import {Button, Drawer, Space} from "antd";

export interface ActionsDrawerLayoutProps extends PropsWithChildren {
    onClose: () => void
    title: string
    showActions?: boolean
    onConfirm: () => void
    confirmLoading: boolean
    open: boolean
}

const ActionsDrawerLayout: React.FC<ActionsDrawerLayoutProps> = ({
                                                                     children,
                                                                     onClose,
                                                                     showActions,
                                                                     onConfirm,
                                                                     confirmLoading,
                                                                     title,
                                                                     open
                                                                 }) => {
    return <>
        <Drawer title={title} width={720} onClose={onClose} open={open} extra={
            (showActions ?? true) ? <Space>
                <Button onClick={() => {
                    onClose()
                }}>取消</Button>
                <Button onClick={onConfirm} type="primary" loading={confirmLoading}>
                    提交
                </Button>
            </Space> : undefined
        }>
            {children}
        </Drawer>
    </>
}

export default ActionsDrawerLayout


